package leetcode.offer;

import java.util.Stack;

/**
 * ClassName: $09_CQueue
 * Description:
 * date: 2021-10-27 17:24
 *
 * @author liyifan
 */
public class CQueue {

    private Stack<Integer> a;

    private Stack<Integer> b;

    public CQueue() {
        a = new Stack<>();
        b = new Stack<>();
    }

    public void appendTail(int value) {
        a.push(value);
    }

    public int deleteHead() {
        if (b.isEmpty()) {
            if (a.isEmpty()) {
                return -1;
            } else {
                while (a.isEmpty()) {
                    b.push(a.pop());
                }
                return b.pop();
            }
        } else {
            return b.pop();
        }
    }

}
